library("colorspace") library("RColorBrewer") hm <- matrix( c(rep(1,3), rep(10,3), rep(100,3)), nrow=3, ncol=3, byrow=TRUE) hm ## modified pal function pal <- function(col, border = NA, ...) { n <- length(col) plot(0, 0, type="n", xlim = c(0, 1), ylim = c(0, 1), axes = FALSE, xlab = "", ylab = "", ...) rect(0:(n-1)/n, .5, 1:n/n, 1, col = col, border = border) } ## replace quartz() with dev.new() or win.graph() on windows quartz(); pal(rainbow_hcl(4)) ## redefine without a box lasagna<- function(X, col=palette, axes=F, ...){ image(t(X)[,(nrow(X):1)], col=col, axes=axes, ... ) ## box() } ## lasagna() uses image(), but manipulates the matrix so the image ## rendered is that of just painting the elements of the matrix. ##palette <- rev(sequential_hcl(5, h=120, c = 80, power = 2.2)) ##palette <- rainbow_hcl(5, start=20, end=310) ##palette <- brewer.pal(6, "PuOr") ##palette <- brewer.pal(5, "PuOr")[c(3,4,2,1,5)] palette <- brewer.pal(11, "PuOr")[c(1,8,3,5,10)] palette <- rainbow_hcl(4) pal(palette) ## replace quartz() with dev.new() or win.graph() on windows quartz(); image(hm) quartz(); image(hm, col=rainbow_hcl(6)) quartz();lasagna(hm, col=palette) quartz();lasagna(hm, col=brewer.pal(3, "PuOr"))